<!--
 * @Author: coman
 * @LastEditors: coman
 * @Date: 2020-06-11 18:43:35
 * @motto: No pain,No gain
 * @LastEditTime: 2020-06-11 19:26:21
--> 
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function countPrime(num1,num2){
            var count = 0;
            for(var i=num1;i<=num2;i++){
                if(i==2){
                    count++;
                    continue;
                }
                for(var j=2;j<i;j++){
                    if(i%j==0){
                        //不是素数跳出循环
                        break;
                    }

                    //遍历到最后一个,证明不是素数
                    if(j+1===i){
                        count++;
                        console.log(i+"是素数");
                    }
                }
            }   
            console.log("共有"+count+"素数");
            
        }
        countPrime(100,200);
    </script>
</body>
</html>